/*
 * WaitingPeriod
 *
 * SJSU CS 149 Spring 2009 Project
 *
 * Copyright 2009 Timmy Yee
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * The WaitingPeriod class records enter and leave times for a process
 * waiting in the ready queue.
 *
 * @author Keven Wong
 * @author Timmy Yee
 */
public class WaitingPeriod
{
    private final double enterTime_;
    private final double leaveTime_;

    /**
     * Constructs a record of waiting in the ready queue for some process.
     *
     * @param enterTime The absolute time when the process entered the
     *                  ready queue.
     * @param leaveTime The absolute time when the process left the
     *                  ready queue.
     */
    public WaitingPeriod(double enterTime, double leaveTime)
    {
        enterTime_ = enterTime;
        leaveTime_ = leaveTime;
    }

    /**
     * Gets the relative time spent in one waiting period in the ready queue.
     *
     * @return The time in this waiting period.
     */
    public double getTime()
    {
        return leaveTime_ - enterTime_;
    }
}

